package com.qf.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import lombok.Getter;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.util.Properties;

/**
 * @author chengqiang
 * @Create 2023-12-01-14:43
 * Description:
 */
@Getter
public enum DBUtils {
    DB;
    private final QueryRunner qr;

    DBUtils() {
        Properties properties = new Properties();
        try {
            properties.load(DBUtils.class.getResourceAsStream("db.properties"));
            DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
            qr = new QueryRunner(dataSource);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
